<!DOCTYPE html>
2019년 4월 비트코인 가격 예측
예측 기간 : 3월 24일 ~ 4월 23일
# options
options(scipen = 999)
"%ni%" = Negate("%in%")
# library
library(cryptor)
library(data.table)
library(plotly)
library(lubridate)
library(h2o)
h2o.no_progress()
# predict_days
predict_days = 30
# get data
# tmp = get_historical_price(fsym="BTC", tsym="KRW", end_time="2019-03-23", unit='hour',limit=1000)
# data = as.data.table(tmp)
data = fread("C:/Users/user/Documents/BITCOIN/input/data.csv")
range(data$time)
## [1] "2013-08-08T06:00:00Z" "2019-03-24T08:00:00Z"
# cut range
data[,date:=as.numeric(gsub("-","",substr(time,1,10)))]
data = data[date>=20181201,]
range(data$time)
## [1] "2018-12-01T00:00:00Z" "2019-03-24T08:00:00Z"
# DM
source("C:/Users/user/Documents/BITCOIN/code/101_BTC200_DM.R")
## >> 101_BTC100_DM done!
# ML
max_models = 100
nfolds = 3
stopping_rounds = 10
stopping_tolerance = 0.001
source("C:/Users/user/Documents/BITCOIN/code/201_BTC200_ML.R")
## Connection successful!
##
## R is connected to the H2O cluster:
## H2O cluster uptime: 1 hours 26 minutes
## H2O cluster timezone: Asia/Seoul
## H2O data parsing timezone: UTC
## H2O cluster version: 3.22.1.1
## H2O cluster version age: 2 months and 24 days
## H2O cluster name: H2O_started_from_R_user_dkl876
## H2O cluster total nodes: 1
## H2O cluster total memory: 3.37 GB
## H2O cluster total cores: 4
## H2O cluster allowed cores: 4
## H2O cluster healthy: TRUE
## H2O Connection ip: localhost
## H2O Connection port: 54321
## H2O Connection proxy: NA
## H2O Internal Security: FALSE
## H2O API Extensions: Algos, AutoML, Core V3, Core V4
## R Version: R version 3.5.2 (2018-12-20)
##
## [1] 0
##
## Job $03017f00000132d4ffffffff$_8974db08263dc376d11e3a1fed8e4f3c was cancelled.
## >> 201_BTC100_ML done!
# plot
plot_ly() %>%
add_trace(data=Y, x=~date, y=~price, type = 'scatter', mode = 'lines+markers', line = list(color = 'blue', width = 1), name="실제값") %>%
add_trace(data=YHAT, x=~date, y=~price, type = 'scatter', mode = 'lines+markers', line = list(color = 'red', width = 1, dash='dot'), name="예측값") %>%
layout(xaxis=list(fixedrange=T, title="date"),yaxis=list(fixedrange=T, title="price"),autosize = F, width = 900) %>%
config(displayModeBar = F)
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()